package com.test.ai.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 2025/8/18 14:17
 * @modifiedBy:
 * @version: 1.0
 */
@Configuration
public class OpenAiConfig {
  @Primary
  @Bean("openAiChatClient")
  public ChatClient openAiChatClient(@Qualifier("openAiChatModel") ChatModel openAiChatModel) {
    return ChatClient.builder(openAiChatModel).build();
  }

  @Bean("openAiChatClientWithRole")
  public ChatClient openAiChatClientWithDefaultRole(
      @Qualifier("openAiChatModel") ChatModel openAiChatModel) {
    return ChatClient.builder(openAiChatModel)
        .defaultSystem("你是尚硅谷教育的一名老师,你精通Java开发,你的名字叫尚硅谷")
        .build();
  }
}
